Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement GRANDPA-GHOST #661

Merged
merged 20 commits into from
Jan 3, 2025
Merged

Implement GRANDPA-GHOST #661

merged 20 commits into from
Jan 3, 2025

Conversation

Grigorov-Georgi
Copy link
Collaborator

@Grigorov-Georgi Grigorov-Georgi commented Dec 17, 2024

Description

GHOST method identifies the "heaviest" block -> the block with the most cumulative votes, from the current voting round. The implementation ensures that the block selection adheres to the threshold of valid votes, recursively including ancestor blocks when direct votes are insufficient.

Fixes #395

@Grigorov-Georgi Grigorov-Georgi self-assigned this Dec 17, 2024
@Grigorov-Georgi Grigorov-Georgi marked this pull request as ready for review January 2, 2025 13:35
@nistanimirov nistanimirov linked an issue Jan 2, 2025 that may be closed by this pull request
@Grigorov-Georgi Grigorov-Georgi removed a link to an issue Jan 2, 2025
@Grigorov-Georgi Grigorov-Georgi linked an issue Jan 2, 2025 that may be closed by this pull request
@Log
@Component
public class GrandpaService {
private final GrandpaState grandpaState;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private final GrandpaState grandpaState;
private final GrandpaState grandpaState;

*
* @return GRANDPA GHOST block as a vote
*/
public Vote getGrandpaGHOST() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public Vote getGrandpaGHOST() {
public Vote getGrandpaGhost() {

Just a personal pref, but I'd rather stick to the naming conventions unless absolutely necessary.

Map<Hash256, BigInteger> blocks = getPossibleSelectedBlocks(threshold, Subround.PRE_VOTE);

if (blocks.isEmpty() || threshold.equals(BigInteger.ZERO)) {
throw new ExecutionFailedException("GHOST not found");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be a good idea to have a custom exception for grandpa/ghost related manners. GrandpaGenericException GhostExecutionException ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest we reuse the existing Subround and move it to the grandpa package in the future.

Copy link

sonarqubecloud bot commented Jan 3, 2025

@Grigorov-Georgi Grigorov-Georgi merged commit 2541946 into dev Jan 3, 2025
3 checks passed
@Grigorov-Georgi Grigorov-Georgi deleted the 395-grandpa-ghost branch January 3, 2025 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GRANDPA GHOST
2 participants